package com.ruoyi.framework.web.service;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.mapper.SysUserMapper;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;


/**
 * @author by dg
 * @date 2023/7/17.
 */
@Service
public class WechatDetailsServiceImpl implements IWechatDetailsService {

    @Resource
    private SysUserMapper sysUserMapper;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
         SysUser sysUser =  sysUserMapper.selectUserByUserName(username);
        if (sysUser == null) {
            throw new UsernameNotFoundException("登录用户/密码错误");
        }
        return new LoginUser(sysUser);
    }

}
